var main = new Vue({
	el: '#main',
	data: {
		hospitalname:'',
		hospitallist:[
//			{
//				hospitalIcon:'../../img/pinggu_sq/10.png',
//				hospitalName:'长海医院',
//				address:'上海杨浦区长海路183号',
//				selected:true,
//			},
//			{
//				hospitalIcon:'../../img/pinggu_sq/10.png',
//				hospitalName:'长海医院2',
//				address:'上海杨浦区长海路183号2',
//				selected:false,
//			}
		],
	
	},
	methods:{
		choose:function(index){
			for (var i=0; i<this.hospitallist.length;i++) {
				if(i==index){
					this.hospitallist[i].selected=true;
				}else{
					this.hospitallist[i].selected=false;
				}
			}
		},
		gaodemap:function(address){
//			window.location.href='gaode.html'
			Location(address)
		}
	},
	watch: {
	    hospitalname:function(){
//		    	this.loading="";
		    	waitingName(this.hospitalname)
	    }
	}

})
var timeid=null;
var loading=false;
function waitingName(hospitalname){
	if(loading){return};
	clearTimeout(timeid);
	timeid=setTimeout(function(){waiting(hospitalname)},1000)	
}

function Location(address){
	ajaxPost(
		Url.PGAPPLY_LATITUDE,
		{
			"address":address
		},
		function (data){
			if(data.status==1){
				window.location.href='gaode.html?longitude='+data.response.longitude+"&latitude="+data.response.latitude+"&name="+address;
			}
		}
	)
}

function waiting(hospitalname,pageNo){
//	console.log(hospitalname)
	loading=true;
	ajaxPost(
		Url.PGAPPLY_PGJG, 
		{
			"pgjgName":hospitalname||'',
		},
		function(data) {
			if(data.status==1){
				for (var i=0;i<data.response.length;i++) {
					data.response[i].selected=false;
					
				}
				main.hospitallist=data.response;
				loading=false;
			}
		}
	)
}
waiting();
function makesure(){
	console.log("jhsdj")
	for(var i=0;i<main.hospitallist.length;i++){
		if(main.hospitallist[i].selected){
			localStorage.hospitalName=main.hospitallist[i].hospitalName;
			localStorage.hospitalNameID=main.hospitallist[i].id;
		}
	}
	localStorage.onloadState = true;
	window.history.go(-1);
}
